#include "mystdio.h"
#include "mystring.h"

int main()
{
    MYFILE *filep = MyFopen("log.txt", "a");
    if (!filep)
    {
        printf("MyFopen error!\n");
        return 1;
    }

    // const char *msg = "hello MyFwrite\n"; // 行刷新
    // MyFwrite(filep, msg, strlen(msg));

    int cnt = 5;
    while (cnt--)
    {
        const char *msg = "hello MyFwrite!"; // 没有'\n',不满足刷新条件,待在缓冲区
        MyFwrite(filep, msg, strlen(msg));
        // 强制刷新缓冲区
        MyFflush(filep);
        printf("buffer:%s\n", filep->outbuffer); // 打印缓冲区内容
        sleep(1);
    }

    MyFcolse(filep);

    const char *str = "hello!\n";
    printf("my_strlen: %d\n", my_strlen(str));
    return 0;
}